package com.caine.globaltransaction.aspect;

import com.caine.globaltransaction.annotation.GlobalTransaction;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

/**
 * @Author: CaineZhu
 * @Description:
 * @Date: Created in 12:53 2020/11/24
 * @Modified By:
 */
@Component
@Aspect
public class CaineGlobalTransactionAspect {

    @Around("@annotation(com.caine.globaltransaction.annotation.GlobalTransaction)")
    public void around(ProceedingJoinPoint point) throws Throwable {
        MethodSignature signature = (MethodSignature)point.getSignature();
        Method method = signature.getMethod();
        GlobalTransaction globalTransaction = method.getAnnotation(GlobalTransaction.class);
        if(globalTransaction.isStart()){

        }

    }
}
